public class MaxSubArray {
    // leetcode 最大子数组和
    // https://leetcode.cn/problems/maximum-subarray/description/?envType=study-plan-v2&envId=top-100-liked
    public int maxSubArray(int[] nums) {
        int max = nums[0], ret = nums[0];
        for (int i = 1; i < nums.length; i++) {
            max = Math.max(max+nums[i],nums[i]);
            ret = Math.max(ret,max);
        }
        return ret;
    }
}
